
#include "read_card.h"
#include "jdq.h"
#include "Delay.h"
#include "OLED.h"
u8 ucArray_ID [ 4 ];  
u8 read_flag = 0;
int t = 0;
u8 GLY[4] = {0xA1,0x7D,0xAA,0x1D};
u8 Normal_Card[6][4];
//u8 Normal2_Card[6][4] = {0,0,0,0,0x53,0x47,0x35,0x9f};
void IC_Check ( void )
{
	char cStr [ 30 ];                                                                                         
	u8 ucStatusReturn;	
		if ( ( ucStatusReturn = PcdRequest ( PICC_REQALL, ucArray_ID ) ) != MI_OK )                                    
			ucStatusReturn = PcdRequest ( PICC_REQALL, ucArray_ID );		                                                 

		if ( ucStatusReturn == MI_OK  )
		{
			if ( PcdAnticoll ( ucArray_ID ) == MI_OK )                                                           
			{
				read_flag = 1;
				sprintf ( cStr, "%d%d%d%d", ucArray_ID [ 0 ], ucArray_ID [ 1 ], ucArray_ID [ 2 ], ucArray_ID [ 3 ] );

				while(PcdAnticoll ( ucArray_ID ) == MI_OK);
   					 
			}			
		}
		

}

void Show_Card(u8 *card)
{
	OLED_ShowHexNum(2,1,card[0],2);
	OLED_ShowHexNum(2,3,card[1],2);
	OLED_ShowHexNum(2,5,card[2],2);
	OLED_ShowHexNum(2,7,card[3],2);
}

int Check_GLY(u8 *card)
{
	if(GLY[0] == ucArray_ID[0] && GLY[1] == ucArray_ID[1] && GLY[2] == ucArray_ID[2]&&GLY[3] == ucArray_ID[3])
	{
		return 1;
	}
	return 0;
}
int Check_Card(u8 *card)
{
	for(int i = 1;i<6;i++)
	{
		if(Normal_Card[i][0]== ucArray_ID[0] && Normal_Card[i][1] == ucArray_ID[1] && Normal_Card[i][2]== ucArray_ID[2]&& Normal_Card[i][3]== ucArray_ID[3])
		{
			return 1;
		}
	}
	return 0;
}